<?php

namespace app\common\library;


use app\common\constant\Common;

/**
 * 流程邮件发送
 */
class Word
{
    public function start(){
        ob_start();
        echo '<html xmlns:o="urn:schemas-microsoft-com:office:office"
                    xmlns:w="urn:schemas-microsoft-com:office:word"
                    xmlns="http://www.w3.org/TR/REC-html40"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
                    <style>
                        body{font-family:"SimSun";}
                        table,table tr th, table tr td { border:1px solid black; }
                        tr{height:38px;}
                        table { width: 1000px; font-weight:normal;font-size:15px; min-height: 25px; line-height: 25px; border-collapse: collapse;text-align: left;}
                    </style>
                    ';
    }

    public function save($path)
    {
        echo "</html>";
        $data = ob_get_contents();
        ob_end_clean();

        $this->wirtefile ($path,$data);
    }

    public function wirtefile ($filename,$data)
    {
        $fp=fopen($filename,"wb");
        fwrite($fp,$data);
        fclose($fp);
    }

    public function writeTrackContent($data, $extData = [])
    {
        $html = '
<div style="width:1000px;margin-left: 50px;">
    <div style="width:100%;height:80px;line-height:80px;text-align:center;font-size:25px;">金陵科技学院对外合作项目执行情况登记表</div>
    <div style="width: 100%">
		<div style="display: inline-block;float: left;margin-left: 50px;margin-bottom: 10px;">填报单位（盖章）：______________</div>
		<div style="display: inline-block; float: right;margin-right: 100px;margin-bottom: 10px;">填报日期：_______________</div>
	</div>
    <table style="width: 100%">
       <tr>
            <th width="30%">合作项目名称</th>
            <th align="left"><span style="margin-left: 10px;">'.$extData['name'].'项目</span></th>
        </tr>
        <tr>
            <th width="30%">合作主要事项（规划处填写）</th>
            <th align="left"><span style="margin-left: 10px;">'.$extData['main_matters'].'</span></th>
        </tr>
        <tr>
            <th width="30%">往年合作事项执行落实情况</th>
            <th align="left"><span style="margin-left: 10px;">'.$extData['previous'].'</span></th>
        </tr>
        <tr>
            <th width="30%">当年合作事项执行落实情况</th>
            <th align="left"><span style="margin-left: 10px;">'.$extData['that'].'</span></th>
        </tr>
        <tr>
            <th width="30%">下一步合作事项执行推进计划</th>
            <th align="left"><span style="margin-left: 10px;">'.$extData['next'].'</span></th>
        </tr>
        <tr>
            <th width="30%">其他需要说明的事项</th>
            <th align="left"><span style="margin-left: 10px;">'.$extData['other'].'</span></th>
        </tr>';
        $html .=    '
    </table>
</div>
</html>
<script >
    window.onload = function () {
        window.print()
    }
</script>
';
        echo $html;
    }

    public function downTrackContent($data, $extData = [])
    {
        $html = '
<div style="width:800px;margin-left: 50px;">
    <div style="width:100%;height:40px;line-height:40px;text-align:center;font-size:25px;">金陵科技学院对外合作项目执行情况登记表</div>
    <br>
    <div>
    填报单位（盖章）：________
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;填报日期：________
    </div>
    <table style="width: 100%">
       <tr>
            <th width="20%">合作项目名称</th>
            <th align="left" style="text-align: left;">'.Common::clearContent($extData['name']).'项目</th>
        </tr>
        <tr>
            <th width="20%">合作主要事项（规划处填写）</th>
            <th align="left" style="text-align: left;">'.Common::clearContent($extData['main_matters']).'</th>
        </tr>
        <tr>
            <th width="20%">往年合作事项执行落实情况</th>
            <th align="left" style="text-align: left;">'.Common::clearContent($extData['previous']).'</th>
        </tr>
        <tr>
            <th width="20%">当年合作事项执行落实情况</th>
            <th align="left" style="text-align: left;">'.Common::clearContent($extData['that']).'</th>
        </tr>
        <tr>
            <th width="20%">下一步合作事项执行推进计划</th>
            <th align="left" style="text-align: left;">'.Common::clearContent($extData['next']).'</th>
        </tr>
        <tr>
            <th width="20%">其他需要说明的事项</th>
            <th align="left" style="text-align: left;">'.Common::clearContent($extData['other']).'</th>
        </tr>';
        $html .=    '
    </table>
</div>
</html>
<script >
    window.onload = function () {
        window.print()
    }
</script>
';
        echo $html;
    }
}
